package mc747.portal.logicas;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.tempuri.WsConsultaClienteLocator;
import org.tempuri.WsConsultaClienteSoap;

import ActionWebService.Hello_messageHelloMessagePort;

import mc747.portal.servlet.Logica;
import mc747.servicos.atendcliente.AtendClienteFactory;

public class Contato implements Logica {

	@Override
	public void executa(HttpServletRequest req, HttpServletResponse res)
			throws Exception {

		Hello_messageHelloMessagePort atendClient = new AtendClienteFactory().AtendCliente();
		
		RequestDispatcher rd;
		String resp =atendClient.helloMessage(req.getParameter("contratante"), 
				req.getParameter("email"), 
				"1", 
				req.getParameter("mensagem")) 
		;
		
		req.setAttribute("erro", resp);
		
		if (resp.equals("Email enviado com sucesso.")){	
			 rd = req.getRequestDispatcher(req
					.getParameter("fwdSuccess"));
		} else {
			rd = req.getRequestDispatcher(req
					.getParameter("fwdFail"));
		}
	
		rd.forward(req, res);
	}
}
